package com.coollang.smartbra.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 * 
 * 作者：陈冬冬
 * 
 * 说明：网络的工具类
 * 
 * 时间：2015-8-28 上午11:34:02
 * 
 */
public class NetUtils {

	public static boolean hasNet(Context context){
		ConnectivityManager connectMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo info = connectMgr.getActiveNetworkInfo();
		if(info!=null)
			return true;
		return false;
	}
	
	/**
	 * 判断是否在Wifi环境下
	 * @param context
	 * @return
	 */
	public static boolean isWifi(Context context) {
		ConnectivityManager connectMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo info = connectMgr.getActiveNetworkInfo();
		if(info!=null && info.getType() == ConnectivityManager.TYPE_WIFI){
			return true;
		}
		return false;
	}
}
